<template>
  <div class="edu-page-warp" v-loading="loading">
    <div class="edu-page-title">方案课程信息</div>
    <el-card shadow="never" body-style="padding: 24px 24px 6px 24px;" style="min-height: 600px;">
      <template v-if="show">
        <courseFormForGraduate v-if="isGraduate" :template-id="templateId" :is-read="isRead"/>
        <courseForm v-else :template-id="templateId" :is-read="isRead"/>
      </template>
    </el-card>
  </div>
</template>

<script>
import courseForm from "../culturetemplate/courseForm";
import * as API from "common/src/api/culture/cultruescheme";
import courseFormForGraduate from "../culturetemplate/graduate/courseForm";

export default {
  name: "myCourse",
  components: {
    courseForm,
    courseFormForGraduate
  },
  data() {
    return {
      loading: false,
      show: false,
      templateId: "",
      isRead: true,
      cultureId: ""
    };
  },
  methods: {
    init() {
      this.getCoutureScheme();
    },
    getCoutureScheme() {
      API.getMyCultureScheme().then(res => {
        if (res && res.code == 200) {
          this.templateId = res.data.templateId;
          this.show = true;
          this.cultureId = res.data.cultureId;
          this.isGraduate(res.data.templateId);
        }
      });
    },
    isGraduate(id) {
      API.getIsGraduate(id, 2).then(res => {
        if (res && res.code == 200) {
          this.isGraduate = res.data == "1";
        }
      });
    }
  },
  created() {
    this.init();
  }
};
</script>

<style scoped>
</style>
